package Service;

import Dao.UserDao;
import bean.customer;

public class UserService {

    private  UserDao userDao = new UserDao();

    //保存用户
    public  void registerUser(customer customer){
        try {
            userDao.saveUser(customer);
        } catch (Exception e) {
            throw new RuntimeException(e);
        }
    }

    public customer login(customer customer){
        return userDao.queryUserByUsernameAndPassword(customer.getPhoneNumber(),customer.getPassword());
    }

    //判断用户是否存在
    public boolean existsUsername(String username){
        if(userDao.queryUserByUsername(username)==null){
            return false;
        }
        return  true;
    }

}
